package com.aspose.cells.a.d;

import com.aspose.cells.Color;
import com.aspose.cells.ImageFormat;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.Point2D.Double;
import java.util.ArrayList;

public class zh {
   public static ArrayList a(Color var0, Color var1, com.aspose.cells.b.a.b.zq var2, int var3, int var4) {
      return zab.a(var0, var1, var2, var3, var4);
   }

   public static zb a(com.aspose.cells.b.a.b.a.zh var0) {
      zb var1 = new zb();
      com.aspose.cells.b.a.b.a.zc var2 = var0.m();
      if (var2 != null) {
         com.aspose.cells.b.a.b.zq var3 = var0.o();
         com.aspose.cells.b.a.b.zq var4 = new com.aspose.cells.b.a.b.zq((float)zaj.c((double)var3.f()), (float)zaj.c((double)var3.g()), (float)zaj.c((double)var3.h()), (float)zaj.c((double)var3.i()));
         double var5 = var0.b().doubleValue();
         Double var7 = new Double((double)(var4.f() + var4.h() / 2.0F), (double)(var4.g() + var4.i() / 2.0F));
         double var8 = (double)var4.h() * Math.abs(Math.cos(var5 * 3.141592653589793D / 180.0D)) + (double)var4.i() * Math.abs(Math.sin(var5 * 3.141592653589793D / 180.0D));
         double var10 = (double)var4.i() * Math.abs(Math.cos(var5 * 3.141592653589793D / 180.0D)) + (double)var4.h() * Math.abs(Math.sin(var5 * 3.141592653589793D / 180.0D));
         java.awt.geom.Rectangle2D.Double var12 = new java.awt.geom.Rectangle2D.Double(var7.getX() - var8 / 2.0D, var7.getY() - var10 / 2.0D, var8, var10);
         com.aspose.cells.b.a.b.a.zi var13 = new com.aspose.cells.b.a.b.a.zi();
         var13.a((float)var5, new com.aspose.cells.b.a.b.zo(var7.getX(), var7.getY()));
         double var14 = var12.getX();
         Color[] var16 = var2.b();
         float[] var17 = var2.a();

         for(int var18 = 1; var18 < var2.b().length; ++var18) {
            double var19 = var12.getWidth() * (double)(var17[var18] - var17[var18 - 1]);
            double var21 = var19;
            if (var18 != var2.b().length - 1) {
               var21 = var19 + 1.0D;
            }

            java.awt.geom.Rectangle2D.Double var23 = new java.awt.geom.Rectangle2D.Double(var14, var12.getY(), var21, var10);
            com.aspose.cells.b.a.b.zo[] var24 = new com.aspose.cells.b.a.b.zo[]{new com.aspose.cells.b.a.b.zo(var23.getX(), var23.getY()), new com.aspose.cells.b.a.b.zo(var23.getX(), var23.getY() + var23.getHeight()), new com.aspose.cells.b.a.b.zo(var23.getX() + var23.getWidth(), var23.getY() + var23.getHeight()), new com.aspose.cells.b.a.b.zo(var23.getX() + var23.getWidth(), var23.getY()), new com.aspose.cells.b.a.b.zo(var23.getX(), var7.getY()), new com.aspose.cells.b.a.b.zo(var23.getX() + var23.getWidth(), var7.getY())};
            var13.a(var24);
            com.aspose.cells.b.a.b.zo[] var25 = new com.aspose.cells.b.a.b.zo[]{var24[0], var24[1], var24[2], var24[3]};
            zn var26 = zn.a(var25, true);
            zg var27 = new zg(var24[4], var24[5], var16[var18 - 1], var16[var18], 1.0F);
            var26.a((com.aspose.cells.b.a.b.zc)var27);
            var1.a((zl)var26);
            var14 += var19;
         }
      }

      return var1;
   }

   public static zb a(com.aspose.cells.b.a.b.a.zk var0) {
      zb var1;
      if (var0.a() == 1) {
         var1 = b(var0);
      } else if (var0.a() == 2) {
         var1 = c(var0);
      } else {
         var1 = b(var0);
      }

      return var1;
   }

   private static zb b(com.aspose.cells.b.a.b.a.zk var0) {
      zb var1 = new zb();
      com.aspose.cells.b.a.b.a.zc var2 = var0.c();
      if (var2 != null) {
         Rectangle2D var3 = var0.d();
         java.awt.geom.Rectangle2D.Double var4 = new java.awt.geom.Rectangle2D.Double(zaj.c(var3.getX()), zaj.c(var3.getY()), zaj.c(var3.getWidth()), zaj.c(var3.getHeight()));
         java.awt.geom.Rectangle2D.Double var5 = new java.awt.geom.Rectangle2D.Double(var4.getX(), var4.getY(), var4.getWidth() / 2.0D, var4.getHeight());
         var1.a((zl)a(var2, var5, true));
         java.awt.geom.Rectangle2D.Double var6 = new java.awt.geom.Rectangle2D.Double(var4.getCenterX(), var4.getY(), var4.getWidth() / 2.0D, var4.getHeight());
         var1.a((zl)a(var2, var6, false));
         java.awt.geom.Rectangle2D.Double var7 = new java.awt.geom.Rectangle2D.Double(var4.getX(), var4.getY(), var4.getWidth(), var4.getHeight() / 2.0D);
         var1.a((zl)b(var2, var7, true));
         java.awt.geom.Rectangle2D.Double var8 = new java.awt.geom.Rectangle2D.Double(var4.getX(), var4.getCenterY(), var4.getWidth(), var4.getHeight() / 2.0D);
         var1.a((zl)b(var2, var8, false));
      }

      return var1;
   }

   private static zb c(com.aspose.cells.b.a.b.a.zk var0) {
      zb var1 = new zb();
      com.aspose.cells.b.a.b.a.zc var2 = var0.c();
      if (var2 != null) {
         Rectangle2D var3 = var0.d();
         java.awt.geom.Rectangle2D.Double var4 = new java.awt.geom.Rectangle2D.Double(zaj.c(var3.getX()), zaj.c(var3.getY()), zaj.c(var3.getWidth()), zaj.c(var3.getHeight()));
         int var5 = var2.b().length;
         java.awt.Color[] var6 = new java.awt.Color[var5];
         float[] var7 = new float[var5];
         boolean var8 = true;

         for(int var9 = 0; var9 < var5; ++var9) {
            int var10 = var9;
            if (var8) {
               var10 = var5 - 1 - var9;
            }

            var6[var9] = var2.b()[var10].d();
            float var11 = var2.a()[var10];
            var7[var9] = var8 ? 1.0F - var11 : var11;
         }

         Double var12 = new Double(var4.getCenterX(), var4.getCenterY());
         var1.a((zl)a(var12, (float)var4.getWidth() / 2.0F, var7, var6));
      }

      return var1;
   }

   private static zb a(com.aspose.cells.b.a.b.a.zc var0, Rectangle2D var1, boolean var2) {
      zb var3 = new zb();
      double var4 = var1.getX();
      Double var6 = null;
      Double var7 = null;
      Double var8 = null;
      Double var9 = null;
      boolean var10 = false;
      if (var2) {
         var6 = new Double(var1.getX(), var1.getY());
         var7 = new Double(var1.getX(), var1.getY() + var1.getHeight());
      } else {
         var10 = true;
         var6 = new Double(var1.getX(), var1.getCenterY());
         var7 = new Double(var1.getX(), var1.getCenterY());
      }

      int var11 = var0.b().length;
      Color[] var12 = new Color[var11];
      float[] var13 = new float[var11];

      int var14;
      for(var14 = 0; var14 < var11; ++var14) {
         int var15 = var14;
         if (var10) {
            var15 = var11 - 1 - var14;
         }

         var12[var14] = var0.b()[var15];
         float var16 = var0.a()[var15];
         var13[var14] = var10 ? 1.0F - var16 : var16;
      }

      for(var14 = 1; var14 < var12.length; ++var14) {
         double var25 = var1.getWidth() * (double)Math.abs(var13[var14] - var13[var14 - 1]);
         double var17 = var1.getHeight() * (double)var13[var14];
         if (var2) {
            var17 = var1.getHeight() * (double)(1.0F - var13[var14]);
         }

         var8 = new Double(var4 + var25, var1.getCenterY() + var17 / 2.0D);
         var9 = new Double(var4 + var25, var1.getCenterY() - var17 / 2.0D);
         double var19 = var25;
         if (var14 != var0.b().length - 1) {
            var19 = var25 + 1.0D;
         }

         java.awt.geom.Rectangle2D.Double var21 = new java.awt.geom.Rectangle2D.Double(var4, var1.getY(), var19, var1.getHeight());
         zg var22 = new zg(new com.aspose.cells.b.a.b.zo((float)var21.getX(), (float)var1.getCenterY()), new com.aspose.cells.b.a.b.zo((float)(var21.getX() + var21.getWidth()), (float)var1.getCenterY()), var12[var14 - 1], var12[var14], 1.0F);
         com.aspose.cells.b.a.b.zo[] var23 = new com.aspose.cells.b.a.b.zo[]{new com.aspose.cells.b.a.b.zo(var6.getX(), var6.getY()), new com.aspose.cells.b.a.b.zo(var7.getX(), var7.getY()), new com.aspose.cells.b.a.b.zo(var8.getX() + 1.0D, var8.getY()), new com.aspose.cells.b.a.b.zo(var9.getX() + 1.0D, var9.getY())};
         zn var24 = zn.a(var23, true);
         var24.a((com.aspose.cells.b.a.b.zc)var22);
         var3.a((zl)var24);
         var4 += var25;
         var6 = new Double(var9.getX(), var9.getY());
         var7 = new Double(var8.getX(), var8.getY());
      }

      return var3;
   }

   private static zb b(com.aspose.cells.b.a.b.a.zc var0, Rectangle2D var1, boolean var2) {
      zb var3 = new zb();
      double var4 = var1.getY();
      Double var6 = null;
      Double var7 = null;
      Double var8 = null;
      Double var9 = null;
      boolean var10 = false;
      if (var2) {
         var6 = new Double(var1.getX() + var1.getWidth(), var1.getY());
         var7 = new Double(var1.getX(), var1.getY());
      } else {
         var10 = true;
         var6 = new Double(var1.getCenterX(), var1.getY());
         var7 = new Double(var1.getCenterX(), var1.getY());
      }

      int var11 = var0.b().length;
      Color[] var12 = new Color[var11];
      float[] var13 = new float[var11];

      int var14;
      for(var14 = 0; var14 < var11; ++var14) {
         int var15 = var14;
         if (var10) {
            var15 = var11 - 1 - var14;
         }

         var12[var14] = var0.b()[var15];
         float var16 = var0.a()[var15];
         var13[var14] = var10 ? 1.0F - var16 : var16;
      }

      for(var14 = 1; var14 < var12.length; ++var14) {
         double var25 = var1.getHeight() * (double)Math.abs(var13[var14] - var13[var14 - 1]);
         double var17 = var1.getWidth() * (double)var13[var14];
         if (var2) {
            var17 = var1.getWidth() * (double)(1.0F - var13[var14]);
         }

         var8 = new Double(var1.getCenterX() - var17 / 2.0D, var4 + var25);
         var9 = new Double(var1.getCenterX() + var17 / 2.0D, var4 + var25);
         double var19 = var25;
         if (var14 != var0.b().length - 1) {
            var19 = var25 + 1.0D;
         }

         java.awt.geom.Rectangle2D.Double var21 = new java.awt.geom.Rectangle2D.Double(var1.getX(), var4, var1.getWidth(), var19);
         zg var22 = new zg(new com.aspose.cells.b.a.b.zo((float)var1.getCenterX(), (float)var21.getY()), new com.aspose.cells.b.a.b.zo((float)var1.getCenterX(), (float)(var21.getY() + var21.getHeight())), var12[var14 - 1], var12[var14], 1.0F);
         com.aspose.cells.b.a.b.zo[] var23 = new com.aspose.cells.b.a.b.zo[]{new com.aspose.cells.b.a.b.zo(var6.getX(), var6.getY()), new com.aspose.cells.b.a.b.zo(var7.getX(), var7.getY()), new com.aspose.cells.b.a.b.zo(var8.getX(), var8.getY() + 1.0D), new com.aspose.cells.b.a.b.zo(var9.getX(), var9.getY() + 1.0D)};
         zn var24 = zn.a(var23, true);
         var24.a((com.aspose.cells.b.a.b.zc)var22);
         var3.a((zl)var24);
         var4 += var25;
         var6 = new Double(var9.getX(), var9.getY());
         var7 = new Double(var8.getX(), var8.getY());
      }

      return var3;
   }

   public static zb a(Point2D var0, float var1, float[] var2, java.awt.Color[] var3) {
      zb var4 = new zb();

      try {
         try {
            double var5 = 0.0D;
            double var7 = var0.getX() - var5;
            double var9 = var0.getY() - var5;
            double var11 = 30.0D;
            double var13 = 1.5D;

            for(int var15 = 1; var15 < var3.length; ++var15) {
               java.awt.Color var16 = var3[var15 - 1];
               java.awt.Color var17 = var3[var15];
               int var18 = var16.getRed();
               int var19 = var16.getGreen();
               int var20 = var16.getBlue();
               int var21 = var17.getRed();
               int var22 = var17.getGreen();
               int var23 = var17.getBlue();
               double var24 = (double)((var2[var15] - var2[var15 - 1]) * var1);
               double var26 = 1.0D;
               if (var24 < var11) {
                  var26 = var24 / var11;
               }

               float var28 = (float)Math.abs(var26 * var13);

               for(double var29 = 0.0D; var29 < var24 + var26 / 2.0D; var5 += var26) {
                  int var31 = (int)((double)var18 + (double)(var21 - var18) * (var29 / var24));
                  int var32 = (int)((double)var19 + (double)(var22 - var19) * (var29 / var24));
                  int var33 = (int)((double)var20 + (double)(var23 - var20) * (var29 / var24));
                  Color var34 = a(var31, var32, var33);
                  zs var35 = new zs(var34, var28);
                  if (var5 > 0.0D) {
                     zn var36 = zn.a(new com.aspose.cells.b.a.b.zq((float)var7, (float)var9, (float)(2.0D * var5), (float)(2.0D * var5)));
                     var36.a = var35;
                     var4.a((zl)var36);
                  }

                  var29 += var26;
                  var7 -= var26;
                  var9 -= var26;
               }
            }
         } catch (Exception var40) {
            com.aspose.cells.a.c.zl.b(var40);
         }

         return var4;
      } finally {
         ;
      }
   }

   private static Color a(int var0, int var1, int var2) {
      if (var0 < 0) {
         var0 = 0;
      }

      if (var0 > 255) {
         var0 = 255;
      }

      if (var1 < 0) {
         var1 = 0;
      }

      if (var1 > 255) {
         var1 = 255;
      }

      if (var2 < 0) {
         var2 = 0;
      }

      if (var2 > 255) {
         var2 = 255;
      }

      return Color.fromArgb(var0, var1, var2);
   }

   public static zb a(com.aspose.cells.b.a.b.zx var0) {
      zb var1 = new zb();
      com.aspose.cells.b.a.b.zj var2 = var0.a();
      com.aspose.cells.b.a.b.zq var3 = var0.d();
      com.aspose.cells.b.a.b.zq var4 = new com.aspose.cells.b.a.b.zq((float)zaj.c((double)var3.f()), (float)zaj.c((double)var3.g()), (float)zaj.c((double)var3.h()), (float)zaj.c((double)var3.i()));
      com.aspose.cells.b.a.b.zo var5 = new com.aspose.cells.b.a.b.zo(var4.f(), var4.g());
      com.aspose.cells.b.a.b.zt var6 = new com.aspose.cells.b.a.b.zt(var4.h(), var4.i());
      if (var2 instanceof com.aspose.cells.b.a.b.za) {
         com.aspose.cells.b.a.d.zh var7 = new com.aspose.cells.b.a.d.zh();
         com.aspose.cells.b.a.b.za var8 = new com.aspose.cells.b.a.b.za(var2.i(), var2.h());
         var8.a(var2.j(), var2.k());
         com.aspose.cells.b.a.b.zi var9 = com.aspose.cells.b.a.b.zi.a((com.aspose.cells.b.a.b.zj)var8);
         var9.a(var2, 0, 0);
         var9.e();

         try {
            var8.a(var7, ImageFormat.getPng());
            var8.d();
            zj var10 = zj.a(var5, var6, var7);
            var7.g_();
            var1.a((zl)var10);
         } catch (Exception var11) {
            com.aspose.cells.a.c.zl.b(var11);
         }
      } else if (var2 instanceof com.aspose.cells.b.a.b.b.zf) {
         zj var12 = new zj(var5, var6, var2.f);
         var1.a((zl)var12);
      }

      return var1;
   }
}
